package com.gomtel.smartdevice.ui.holder;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.gomtel.smartdevice.R;
import com.gomtel.smartdevice.base.BasicHolder;
import com.gomtel.smartdevice.global.WatchApplication;
import com.gomtel.smartdevice.moudle.db.entity.AtrialFibrillationInfo;
import com.gomtel.smartdevice.moudle.db.entity.BdDataInfo;

/**
 * Created by Administrator on 2018/5/26 0026.
 */

public class AtrialFibrillationHolder extends BasicHolder<Object> {

    private Context context;
    private TextView view_1;
    private TextView view_2;
    private TextView view_5;

    public AtrialFibrillationHolder(Context context) {
        this.context = context;
    }

    @Override
    public View initHolderView() {
        View view = View.inflate(WatchApplication.getInstance(), R.layout.item_ecg_data, null);
        view_1 = (TextView) view.findViewById(R.id.view_1);
        view_2 = (TextView) view.findViewById(R.id.view_2);
        view_5 = (TextView) view.findViewById(R.id.view_5);
        return view;
    }

    @Override
    public void bindData(Object data) {
        AtrialFibrillationInfo atrialFibrillationInfo = (AtrialFibrillationInfo) data;
        String atrialFibrillationStatus = atrialFibrillationInfo.getAtrialFibrillationStatus();
        int heartRateStatus = Integer.valueOf(atrialFibrillationInfo.getHeartRateStatus());
        if ("0".equals(atrialFibrillationStatus)) {
            view_1.setTextColor(context.getResources().getColor(R.color.blue_style));
            view_1.setText("正常");
        } else if ("1".equals(atrialFibrillationStatus)) {
            view_1.setTextColor(context.getResources().getColor(R.color.red_style));
            view_1.setText("心率不齐");
        } else {
            view_1.setTextColor(context.getResources().getColor(R.color.red_style));
            view_1.setText("疑似房颤");
        }
        if (heartRateStatus > context.getResources().getInteger(R.integer.heart_rate_max) || heartRateStatus < context.getResources().getInteger(R.integer.heart_rate_min)) {
            view_2.setTextColor(context.getResources().getColor(R.color.red_style));
        } else {
            view_2.setTextColor(context.getResources().getColor(R.color.blue_style));
        }
        view_2.setText(atrialFibrillationInfo.getHeartRateStatus());
        view_5.setText(atrialFibrillationInfo.getRecentlyTime());
    }

}
